package cn.tedu.flinkbasic.dataset;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;

import java.util.ArrayList;
import java.util.List;

/**
 * 针对Source的联系
 */
public class SourceDemo {
    public static void main(String[] args) throws Exception {
        //1.获取执行环境
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        //2.获取数据源
//        DataSource<String> source = env.fromElements("123", "haha");
//        List<String> list = new ArrayList<>();
//        list.add("hadoop");
//        list.add("flume");
//        list.add("kafka");
//        list.add("hadoop");
//        DataSource<String> source = env.fromCollection(list);
        DataSource<String> source = env.readTextFile("data.txt");
//      env.readTextFile("hdfs://hadoop01:9000/data/a.txt");
        //3.转换数据
        //TODO
        //4.打印结果
        source.print();
        //5.触发执行
        //暂时不需要
    }
}
